<?php

namespace App\Http\Controllers\OpenShop\Merchant;

use App\Http\Controllers\BaseController;
use App\Service\System\SystemNoticeService;
use Illuminate\Http\Request;

class SystemNoticeController extends BaseController
{
    //系统公告
    public function index(Request $request)
    {
        $shopId = (int)$request->header('shopId');
        return $this->success(SystemNoticeService::getNoticeByShopId($shopId));
    }

    public function read(Request $request)
    {
        $this->validate($request, [
            'noticeId' => 'required|numeric',
            'type'     => 'required|numeric',
        ]);
        $noticeId = $request->noticeId;
        $type   = $request->type;
        $shopId = (int)$request->header('shopId');
        SystemNoticeService::read($noticeId, $shopId, $type);
        return $this->success();
    }

}
